package com.xjgc.eip.twice.zxjeip2czzzz.service.impl;

import java.text.SimpleDateFormat;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.jeecg.common.api.vo.Result;
import org.springframework.stereotype.Service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.xjgc.common.constant.Consants;
import com.xjgc.eip.twice.zxjeip2cccjc.entity.ZxjEip2cCcjc;
import com.xjgc.eip.twice.zxjeip2czzzz.entity.ZxjEip2cZzzz;
import com.xjgc.eip.twice.zxjeip2czzzz.mapper.ZxjEip2cZzzzMapper;
import com.xjgc.eip.twice.zxjeip2czzzz.service.ZxjEip2cZzzzService;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhanghongbin
 * @since 2019-11-23
 */
@Service
public class ZxjEip2cZzzzServiceImpl extends ServiceImpl<ZxjEip2cZzzzMapper, ZxjEip2cZzzz> implements ZxjEip2cZzzzService {

    @Override
    @DS("proxyDs")
    public Boolean updateBatch(List<ZxjEip2cZzzz> data) {
        boolean flag = false;
        Result<ZxjEip2cZzzz> result = new Result<ZxjEip2cZzzz>();
        if(data==null || data.size() == 0) {
            result.error500("参数不识别！");
        }else {
            SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
            List<String> ht = Lists.newArrayList();
            QueryWrapper<ZxjEip2cCcjc> queryWrapper=new QueryWrapper<>();
            for (ZxjEip2cZzzz zzzz : data){
                zzzz.setIoflag(Consants.ZZJC_SP);
            }
            super.updateBatchById(data);
            flag = true;
        }
        return flag;
    }
    @Override
    @DS("proxyDs")
    public Result<IPage<ZxjEip2cZzzz>> queryPageList(ZxjEip2cZzzz zzzz, Integer pageNo, Integer pageSize, HttpServletRequest req) {
        Result<IPage<ZxjEip2cZzzz>> result = new Result<IPage<ZxjEip2cZzzz>>();
        QueryWrapper<ZxjEip2cZzzz> queryWrapper = new QueryWrapper<>();
        queryWrapper.setEntity(zzzz);
        queryWrapper.eq("\"IOFLAG\"", Consants.Unread);
        /* QueryWrapper<ZxjEip2cZzjc> queryWrapper = QueryGenerator.initQueryWrapper(zzjc, req.getParameterMap());*/
        //queryWrapper.eq("\"REVIEW_STATUS\"", Consants.REVIEW_STATUS0);
        Page<ZxjEip2cZzzz> page = new Page<ZxjEip2cZzzz>(pageNo, pageSize);
        IPage<ZxjEip2cZzzz> pageList = super.page(page, queryWrapper);
        result.setSuccess(true);
        result.setResult(pageList);
        return result;
    }
}
